package com.ithzl.capacity.pojo.RESTful;

import com.ithzl.capacity.pojo.constant.Constant;
import lombok.Data;

@Data
public class RestBean {
    private int code;
    private Object data;
    private String mag;

    public RestBean(int code, Object data, String mag) {
        this.code = code;
        this.data = data;
        this.mag = mag;
    }

    public RestBean() {
    }

    /**
     * 成功
     * @param date
     * @return
     */
    public static RestBean succeed(Object date){
        return new RestBean(Constant.REST_SUCCEED_CODE,date,null);
    }
    public static RestBean succeed(){
        return new RestBean(Constant.REST_SUCCEED_CODE,null,null);
    }
    public static RestBean succeed(Object data,String mag){
        return new RestBean(Constant.REST_SUCCEED_CODE,data,mag);
    }

    /**
     * 失败
     * @param mag
     * @return
     */
    public static RestBean fail(String mag){
        return new RestBean(Constant.REST_FAIL_CODE,null,mag);
    }

    /**
     * 异常
     * @return
     */
    public static RestBean abnormal(){
        return new RestBean(Constant.REST_ABNORMAL_CODE,null,"服务器出现错误，请通知工作人员");
    }
}
